import React, { Component } from 'react';
import { routerRedux } from 'dva/router';
import { connect } from 'dva';
import {  Flex, WingBlank,WhiteSpace,Icon } from 'antd-mobile';
import myWalletsvg from"../../assets/img/myWallet.svg";
import { myWallet } from './myWallet.less';


class MyWallet extends Component {
    render() {
        const { data, YE = "0.00" } = this.props;
        return (
            <div className={myWallet}>
                <WingBlank>
                    <WhiteSpace size="sm"/>
                    <Flex  style={{borderBottom:"1px solid #e5e5e5",padding:".2rem 0"}} >
                            <Icon className="wallet_logo" type={myWalletsvg.id}/>
                            <div>我的钱包</div>
                    </Flex>
                    <Flex  className="wallet_list" justify="between">
                        <div onClick={()=>{
                                // if (!token) return false;
                            if(this.props.token!=null){
                            let arr=[YE, data.freezePredeposit]
                            this.props.dispatch(routerRedux.push({
                                pathname: `/balance/${arr}`,
                            }));}
                        }}>
                            <p>¥ <span>{ YE || 0 }</span></p>
                            <p>余额</p>
                        </div>
                        <div style={{height:'0.6rem',border:".01rem solid #e5e5e5",width:"1px"}}/>
                        <div onClick={()=>{
                            if(this.props.token!=null){
                            let arr=[YE,data.freezePredeposit]
                            this.props.dispatch(routerRedux.push({
                                pathname: `/balance/${arr}`,
                            }));}
                        }}>
                            <p>¥ <span>{ data.freezePredeposit || 0 }</span></p>
                            <p>锁定余额</p>
                        </div>
                        <div style={{height:'0.6rem',border:".01rem solid #e5e5e5",width:"1px"}}/>
                        <div onClick={()=>{
                            if(this.props.token!=null){
                            this.props.dispatch(routerRedux.push({
                                pathname: `/couponList/${0}`,
                            }));}
                        }}>
                            <p>{ data.couponCount || 0}</p>
                            <p>优惠券</p>
                        </div>
                    </Flex>
                    <WhiteSpace size="sm"/>
                </WingBlank>
            </div>
        );
    }
}

export default connect(({ myWallet }) => ({ myWallet }))(MyWallet);
